/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.rcs.filesystem;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
import org.rcs.servlets.utils.FileUtils;
import org.rcs.folders.AbstractItem;

/**
 *
 * @author pablo
 */
public class FileItem extends AbstractItem {

  private File file;

  public FileItem(File file) {
    this.file = file;
  }

  @Override
  public Date getModifiedDate() {
    return FileUtils.getFileDate(file);
  }
  
  @Override
  public long getContentLength() {
    return file.length();
  }

  @Override
  public String getName() {
    return file.getName();
  }

  @Override
  public String getContentType() {
    return "application/octet-stream";
  }

  @Override
  protected void sendContentRange(OutputStream output, long start, long length) throws IOException {
    FileUtils.copyFileToStream(file, output, start, length);
  }
}
